$(function(){


    //banner图绑定

        $.ajax({
            url: "../banner/list.do",
            async: false,
            type: "post",
            dataType: "json",
            data: {cid: 801},
            success: function (data) {/*console.info(data.data);*/
                var $varietyContent = $('#hBan'), varietyHtml = template('banner', data);
                $varietyContent.html(varietyHtml);
                ;(function($){
                    var oUl=$('#hBan');
                    var aShow=$('#hBan li');
                    var aAct=$('#banAct i');
                    var oShow=$('#hBan li:first');

                    var oLeft=oShow.width();
                    var now=0;
                    var timer=null;

                    aAct.click(function(){
                        now=$(this).index();
                        tab();
                    });

                    timer=setInterval(next,5000);

                    oUl.mouseover(function(){
                        clearInterval(timer);
                    });
                    oUl.mouseout(function(){
                        timer=setInterval(next,5000);
                    });

                    aAct.mouseover(function(){
                        clearInterval(timer);
                    });
                    aAct.mouseout(function(){
                        timer=setInterval(next,5000);
                    });

                    function next(){
                        now++;
                        if(now==aShow.length){
                            now=0;
                            oUl.animate({marginLeft:-oLeft*now},0);
                        }
                        tab();
                    }
                    function tab(){
                        aAct.removeClass('listAShow');
                        aAct.eq(now).addClass('listAShow');
                        oUl.animate({marginLeft:-oLeft*now},500);
                    }
                })(jQuery);

            }


        })

//最新资讯
    geetdata("../articledetail/list.do", {
        cid:101,
        status:1
        /*pageNo:1,
         pageSize:7*/
    }, "#lizi1", "lizi1_list", null, false, function(){
        $(".right li").hover(function(){
            $(this).find("i").css({"background":"url('images/gRound1.png') no-repeat"});
        },function(){
            $(this).find("i").css({"background":"url('images/gRound.png') no-repeat"});
        });
    });
   /* var date=[];
    $.ajax({
        url :  "../articledetail/list.do?cid=101",
        dataType : "json",
        success :function(data){
            if(data.statusCode==="200"){
                for(var d=0; d< data.data.length; d++){
                    var update = data.data[d].publishTime;
                    date.push('<span class="date">'+update+'</span>');
                    $(".gContent1 .right li a").eq(d).append(date[d]);

                }

            }
        }
    });

*/



  /*  var news=[];
    $.ajax({
        url :  "../articledetail/list.do?cid=101&status=1",
        dataType : "json",
        success :function(data){
            if(data.statusCode==="200"){
                for(var d=0; d< data.data.length; d++){
                    var summary = data.data[d].title;
                    news.push('<a href="#">'+summary+'<span class="more">详情</span></a>');
                    $(".gContent1 .right li").eq(d).append(news[d]);
                }

            }
        }
    });*/






    $(".gContent2 li").hover(function(){
        $(this).find(".one").css("color","#fff");
        $(this).find(".three").css("background","#fff");
    },function(){
        $(this).find(".one").css("color","#5e5e5e");
        $(this).find(".three").css("background","#f00");
    });

//最新公告
    var html='';
    $.ajax({
        url :  "../articledetail/list.do?cid=903&status=1",
        dataType : "json",
        success :function(data){
            if(data.statusCode==="200"){
                for(var d=0; d< data.data.length; d++){
                    var title = data.data[d].title;
                    html+=(('<li>'+title+'</li>'));
                }
                $(".gshow ul").html(html);
                var $gshow = $(".gIcon li");
                var $gWidth = $gshow[0].offsetWidth;
                //alert($gWidth);
                var $gUl = $(".gIcon ul");
                var $timer = null;
                var $gLeft = $gUl.css("marginLeft");
                var aa =parseInt($gLeft);
                //console.log(aa--);
                var widthAll = 0;
                $(".gshow ul li:first-child").addClass("gfirst");
                $gshow.each(function(i) {
                    //alert($(this)[0].offsetWidth)
                    widthAll += $(this)[0].offsetWidth;
                });
                $gUl.css("width",widthAll);
                $(".gshow").css("width",$gWidth);
                function gactive(){
                    aa--;
                    $gUl.css("marginLeft",aa);
                    if(aa==-widthAll){
                        aa = 0;
                    };
                };
                $timer=setInterval(gactive,20);


                if($gLeft==widthAll){
                    $gUl.css("marginLeft","0px");
                };
            }
        }
    });


    $.ajax({
        url :  "../articledetail/list.do",
        dataType : "json",
        success :function(data){
            if(data.statusCode==="200"){
                for(var d=0; d< data.data.length; d++){
                    var gImg = data.data[d].imgUrl;
                    $(".gContent2 .container .right .day img").eq(0).attr("src",gImg);

                }

            }
        }
    });

    var datailHtml=[];
    $.ajax({
        url :  "../articledetail/list.do",
        dataType : "json",
        success :function(data){
            if(data.statusCode==="200"){
                for(var d=0; d< data.data.length; d++){
                    var detail = data.data[d].summary;
                    datailHtml.push(detail);
                    $(".gContent2 .container .right .day p").eq(d).html(datailHtml[d]);

                }

            }
        }
    });

//FIXED
        var aFixA=$(" #dFix li");
        var aFixAll=$(' #dFix li a');
        var aFixP=$(' #dFix .L1 p');
        var aFixImg=$(' #dFix .L2 img');
        var aFixI3=$(' #dFix .L3 .a3 i');
        var oScroll=$('#xJsScroll');

        aFixAll.mouseover(function(){
            $(this).css('background','#16263f');
        });
        aFixAll.mouseout(function(){
            $(this).css('background','#d2d2d2');
        });

        aFixA.eq(0).mouseover(function(){
            aFixP.css('display','block');
        });
        aFixA.eq(0).mouseout(function(){
            aFixP.css('display','none');
        });

        aFixA.eq(1).mouseover(function(){
            aFixImg.css('display','block');
        });
        aFixA.eq(1).mouseout(function(){
            aFixImg.css('display','none');
        });

        aFixA.eq(2).mouseover(function(){
            aFixI3.addClass('iShow');
        });
        aFixA.eq(2).mouseout(function(){
            aFixI3.removeClass('iShow');
        });

        oScroll.click(function(){
                $('html,body').animate({scrollTop: '0px'}, 500);
            }
        );



});